package com.bootx.service;

import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * @author black
 */
public interface RedisService {

    // ========================= 字符串操作 =========================
    void setString(String key, String value);

    String getString(String key);

    void deleteString(String key);

    // ========================= 数字操作 =========================
    void setNumber(String key, long value);

    long getNumber(String key);

    long increment(String key, long delta);

    void deleteNumber(String key);

    // ========================= List 泛型操作 =========================
    <T> void addToList(String key, T value);

    <T> void addAllToList(String key, List<T> values);

    <T> List<T> getList(String key, int startIndex, int count, Class<T> clazz);

    <T> List<T> getListFromEnd(String key, int count, Class<T> clazz);

    <T> void updateListAtIndex(String key, int index, T value);

    void removeFromList(String key, Object value);

    void removeFromListByIndex(String key, int index);

    void clearList(String key);

    void delete(String key);

    Boolean hasKey(String key);

    Long increment(String key);

    <K, V> void putMapValue(String key, K mapKey, V mapValue);

    <K, V> void putAllMap(String key, Map<K, V> mapData);

    <V> V getMapValue(String key, Object mapKey, Class<V> clazz);

    <K, V> Map<K, V> getAllMap(String key, Class<K> keyClass, Class<V> valueClass);

    void removeMapKey(String key, Object mapKey);

    void clearMap(String key);

}
